package com.kingwang.demo.springsecuritytokendemo.security.sso;

import com.kingwang.demo.springsecuritytokendemo.security.sso.authenticator.SsoAuthenticator;
import com.kingwang.demo.springsecuritytokendemo.security.sso.authenticator.impl.ShanDongSsoAuthenticator;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class SsoAuthenticatorFactory {
    private static final String PROVINCE_BEIJING = "11";

    private static final String PROVINCE_ZHEJIANG = "33";

    private static final String PROVINCE_SHANDONG = "37";

    private static final String PROVINCE_GUANGDONG = "44";

    private static final String PROVINCE_HAINAN = "46";

    public static SsoAuthenticator create(HttpServletRequest request) {
        String areaCode = request.getParameter("area");

        switch (areaCode) {
            case PROVINCE_SHANDONG:
                return new ShanDongSsoAuthenticator(areaCode, request);
            default:
                throw new IllegalArgumentException("缺少第三方单点登录认证器：area[" + areaCode + "]");
        }
    }
}
